<?php
/**
 * @category Goatherd
 * @package Goatherd\Commons
 *
 * @author Copyright (c) 2012 Maik Penz <maik@phpkuh.de>
 * @version $Id: IEntity.php 77 2012-03-27 07:53:54Z maik@phpkuh.de $
 *
 * This file is part of Goatherd library.
 *
 * Goatherd library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Goatherd library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Goatherd library. If not, see <http://www.gnu.org/licenses/>.
 */
namespace Goatherd\Commons\Collection;

/**
 * Entity interface.
 *
 * Entities are consired to be extendable replacements for stdClass objects.
 *
 * @category Goatherd
 * @package Goatherd\Commons
 * @subpackage Entity
 */
interface IEntity
{
    /**
     *
     * @param scalar       $key
     * @return mixed       $value
     * @throws \OutOfBoundsException        if key is not known
     */
    public function __get($key);

    /**
     *
     * @param scalar       $key
     * @param mixed        $value
     * @throws \OutOfBoundsException        if not writable for some key
     * @throws \InvalidArgumentException    if restricting value for some key
     */
    public function __set($key, $value);

    /**
     *
     * @param mixed $key
     * @throws \OutOfBoundsException
     */
    public function __unset($key);

    /**
     *
     * @param scalar       $key
     * @return boolean
     */
    public function __isset($key);

    /**
     *
     * @param boolean|null $writable        new value or null [=null]
     * @return boolean                      old value
     */
    public function isWritable($writable = null);

    /**
    * Get entity properties.
    *
    * @return array    $properties
    */
    public function getProperties();
}
